package com.offcn.sms.listener;

import com.offcn.utils.SmsUtil;
import org.apache.http.HttpResponse;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @Author: zola
 * @Date: 2021/9/15 - 09 - 15 - 23:40
 * @Description: com.offcn.sms.listener
 * @Version: 1.0
 */
@Component
public class SmsListener {

    @RabbitListener(queues = "dongyimai.sms.service")
    public void getMessage(Map<String, String> map){
        if (map == null) {
            return;
        }
        try {
            HttpResponse httpResponse = SmsUtil.sendSms(map.get("mobile"), map.get("code"));
            System.out.println(httpResponse);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
